/**
 * 
 */
package com.daily.expenses;

import com.daily.expenses.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;

/**
 * @author No3x
 * 
 */
public class Splashscreen extends Activity {
	protected int _splashTime = 3000; /* was: 300 */
	protected Handler _exitHandler = null;
	protected Runnable _exitRunnable = null;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splashscreen);

		// Runnable exiting the splash screen and launching the menu
		_exitRunnable = new Runnable() {
			@Override
			public void run() {
				exitSplash();
			}
		};

		// Run the exitRunnable in in _splashTime ms
		_exitHandler = new Handler();
		_exitHandler.postDelayed(_exitRunnable, _splashTime);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			// Remove the exitRunnable callback from the handler queue
			_exitHandler.removeCallbacks(_exitRunnable);
			// Run the exit code manually
			exitSplash();
		}
		return true;
	}

	private void exitSplash() {
		// startActivity(new Intent(this, MainActivity.class));
		startActivity(new Intent(this, Dashboard.class));
		super.finish();
	}

}
